<template>
	<view class="gjl-view">
		<!-- #ifdef H5 -->
		<loginH5 @loginSuccess="loginSuccess" v-if="vuex_scopes == 'h5'"></loginH5>
		<loginH5WX @loginSuccess="loginSuccess" v-else></loginH5WX>
		<!-- #endif -->
		<!-- #ifdef MP-TOUTIAO -->
		<loginMpTt @loginSuccess="loginSuccess" :needPhone="needPhone"></loginMpTt>
		<!-- #endif -->
		<!-- #ifdef MP-WEIXIN -->
		<loginMpWx @login="login" @loginSuccess="loginSuccess" :needPhone="needPhone"></loginMpWx>
		<!-- #endif -->
		<!-- #ifdef APP-PLUS -->
		<loginAppAndroid @loginSuccess="loginSuccess" v-if="appName == 'android'"></loginAppAndroid>
		<loginAppIos @loginSuccess="loginSuccess" v-else></loginAppIos>
		<!-- #endif -->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	// #ifdef H5
	import loginH5 from '../components/login/login-h5.vue';
	import loginH5WX from '../components/login/login-h5-wx.vue';
	// #endif
	// #ifdef MP-TOUTIAO
	import loginMpTt from '../components/login/login-mp-tt.vue';
	// #endif
	// #ifdef MP-WEIXIN
	import loginMpWx from '../components/login/login-mp-wx.vue';
	// #endif
	// #ifdef APP-PLUS
	import loginAppAndroid from '../components/login/login-app-android.vue';
	import loginAppIos from '../components/login/login-app-ios.vue';
	// #endif
	export default {
		components: {
			// #ifdef H5
			loginH5,
			loginH5WX,
			// #endif
			// #ifdef MP-TOUTIAO
			loginMpTt,
			// #endif
			// #ifdef MP-WEIXIN
			loginMpWx,
			// #endif
			// #ifdef APP-PLUS
			loginAppAndroid,
			loginAppIos
			// #endif
		},
		data() {
			return {
				needPhone: false,
				appName: 'android',
				query: {}
			}
		},
		onLoad(item) {
			this.query = item;
		},
		mounted() {
			let that = this;
			uni.$on('needPhone',this.showPhone);
			this.appName = uni.getSystemInfoSync().platform;
		},
		methods: {
			// 登录
			login(type) {
				let that = this;
			},
			// api登录
			apiLogin(type, obj) {
				if (type == 'MP-WEIXIN') {
					// this.$apis.wxAutoLogin()
				}
			},
			// 登录成功
			loginSuccess(res) {
				this.$store.dispatch("Login", res);
				this.$refs.uToast.show({
					title: '登录成功',
					// 如果不传此type参数，默认为default，也可以手动写上 type: 'default'
					type: 'success', 
					// 如果不需要图标，请设置为false
					icon: false,
					back: true
				})
			},
			// 登录需要注册绑定手机号
			showPhone(){
				this.needPhone = true
			}
		},
		beforeDestroy() {
			uni.$off(['needPhone', this.showPhone])
		}
	}
</script>

<style>
	page{
		height: 100%;
	}
</style>
<style scoped lang="scss">
	.gjl-view{
		height: 100%;
	}
</style>
